<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>在线销售管理员介面</title>
    <%= stylesheet_link_tag "../javascripts/ext/resources/css/ext-all.css" %>
    <%= stylesheet_link_tag "/stylesheets/blue.css" %>
    <%= stylesheet_link_tag "/stylesheets/tasks.css" %>
    <%= stylesheet_link_tag "/stylesheets/images.css" %>
    <%= stylesheet_link_tag "/stylesheets/Multiselect.css" %>
    <%= javascript_include_tag "/javascripts/ext/adapter/prototype/prototype.js" %>
    <%= javascript_include_tag "/javascripts/ext/adapter/prototype/scriptaculous.js" %>
    <%= javascript_include_tag "/javascripts/ext/adapter/prototype/effects.js" %>
    <%= javascript_include_tag "/javascripts/ext/adapter/prototype/ext-prototype-adapter.js" %>
    <!-- LIBS --><%if session[:explorer_info]=="IE" %>
  <%= javascript_include_tag "/javascripts/ext/adapter/ext/ext-base.js" %>
<%end %>
    <!-- ENDLIBS --><%= javascript_include_tag "/javascripts/ext/ext-all-debug.js" %>
<%= javascript_include_tag "/javascripts/ext/examples.js" %>
<%= javascript_include_tag "/javascripts/ext/build/locale/ext-lang-zh_CN.js" %>
<%= javascript_include_tag "/javascripts/Multiselect.js" %>
<%= javascript_include_tag "/javascripts/DDView.js" %>
<%= javascript_include_tag "/javascripts/application.js" %>
    <script>var tabs;</script>
  </head>
  <body>
    <script>
        /*
         * Ext JS Library 2.1
         * Copyright(c) 2006-2008, Ext JS, LLC.
         * licensing@extjs.com
         *
         * http://extjs.com/license
         */
        //var tabs;
        Ext.apply(Ext.form.VTypes, {
            daterange: function(val, field){
                var date = field.parseDate(val);

                // We need to force the picker to update values to recaluate the disabled dates display
                var dispUpd = function(picker){
                    var ad = picker.activeDate;
                    picker.activeDate = null;
                    picker.update(ad);
                };
                if (field.startDateField) {
                    var sd = Ext.getCmp(field.startDateField);
                    sd.maxValue = date;
                    if (sd.menu && sd.menu.picker) {
                        sd.menu.picker.maxDate = date;
                        dispUpd(sd.menu.picker);
                    }
                }
                else if (field.endDateField) {
                    var ed = Ext.getCmp(field.endDateField);
                    ed.minValue = date;
                    if (ed.menu && ed.menu.picker) {
                        ed.menu.picker.minDate = date;
                        dispUpd(ed.menu.picker);
                    }
                }
                /* Always return true since we're only using this vtype
                 * to set the min/max allowed values (these are tested
                 * for after the vtype test)
                 */
                return true;
            },

            password: function(val, field){
                if (field.initialPassField) {
                    var pwd = Ext.getCmp(field.initialPassField);
                    return (val == pwd.getValue());
                }
                return true;
            },
            passwordText: '密码不匹配'
        });
        Ext.onReady(function(){
            Ext.QuickTips.init();
            Ext.form.Field.prototype.msgTarget = 'side';
            tabs = new Ext.TabPanel({
                id: 'tabs',
                region: 'center',
                activeTab: 0,
                width: '100%',
                height: 700,
                plain: true,
                defaults: {
                    autoScroll: true
                },
                items: [{
                        id: 'tab_happy_right',
                        title: '欢迎登录!',
                        autoLoad: {
                            url: '/index/happy_welcome', //params: 'id=1'
                            scripts: true
                        }
                    }]
            });

            var flightActions = new Ext.Panel({
                frame: true,
                title: '航班查询',
                collapsible: true,
                contentEl: 'flights_mangaer',
                titleCollapse: true
            });

            var priceActions = new Ext.Panel({
                frame: true,
                title: '运价管理',
                collapsible: true,
                contentEl: 'price_manager',
                titleCollapse: true
            });

            var ordersActions = new Ext.Panel({
                frame: true,
                title: '定单管理',
                collapsible: true,
                contentEl: 'orders_manager',
                titleCollapse: true
            });

            var userActions = new Ext.Panel({
                frame: true,
                title: '用户资料',
                collapsible: true,
                contentEl: 'users_infos',
                titleCollapse: true
            });
            var actionPanel = new Ext.Panel({
                id: 'action-panel',
                region: 'west',
                split: true,
                collapsible: true,
                collapseMode: 'mini',
                width: 160,
                minWidth: 150,
                border: false,
                baseCls: 'x-plain',
                items: [flightActions, priceActions,ordersActions, userActions]
            });
            new Ext.Viewport({
                enableTabScroll: true,
                layout: "border",
                items: [{
                        title: "面板",
                        region: "north",
                        height: 50,
                        html: "<h1>机票在线销售系统后台管理!</h1>"
                    }, actionPanel, tabs]
            });
            //tabs.getActiveTab().getUpdater().update("/index/index");
            //Ext.MessageBox.alert('提示', tabs.getActiveTab().getUpdater());
            //happy_right.getUpdater().update("http://www.163.com");

            var ab = actionPanel.body;
            ab.on('mousedown', doAction, null, {
                delegate: 'a'
            });
            ab.on('click', Ext.emptyFn, null, {
                delegate: 'a',
                preventDefault: true
            });

            var actions = {
                'price_query': function(){
                    var panel = tabs.getItem(0);
                    panel.getUpdater().update('/ticket/price_query');
                    panel.setTitle('航班查询');
                },
                //普通运价
                'common_price_release': function(){
                    var panel = tabs.getActiveTab();
                    panel.getUpdater().update('/web_admin/common_price_release');
                    panel.setTitle('普通运价发布');
                    //Ext.MessageBox.alert('提示', '你好');
                },
                //运价列表
                'price_released_list': function(){
                    var panel = tabs.getActiveTab();
                    panel.getUpdater().update('/web_admin/price_released_list');
                    //Ext.MessageBox.alert('提示', '你好');
                },
                //定单管理之定单查询
                'query_all_order': function(){
                    var panel = tabs.getActiveTab();
                    panel.getUpdater().update('/web_admin/query_all_order');
                },

                //所有用户列表
                'all_users': function(){
                    var panel = tabs.getActiveTab();
                    panel.getUpdater().update('/web_admin/webUserList');
                },

                //我的资料之修改密码
                'password_info': function(){
                    var panel = tabs.getActiveTab();
                    panel.getUpdater().update('/web_user/password_info');
                },

                //我的资料之退出系统
                'agent_logout': function(){
                    window.document.location.href = "/index/agent_logout";
                }
            };

            function doAction(e, t){
                e.stopEvent();
                //Ext.MessageBox.alert('提示', t.id);
                actions[t.id]();
            }
        });
    </script>
    <ul id="flights_mangaer">
      <li id="new-task">
        <img src="/images/system/blue_point.gif"/><a id="price_query" href="#">航班查询</a>
      </li>
    </ul>
    <ul id="price_manager">
      <li>
        <img src="/images/system/blue_point.gif" class="icon-active"/><a id="price_released_list" href="#">运价管理</a>
      </li>
    </ul>
    <ul id="orders_manager" class="x-hidden">
      <li>
        <img src="/images/system/blue_point.gif" class="icon-show-all"/><a id="query_all_order" href="#">订单查询</a>
      </li>
    </ul>
    <ul id="users_infos">
      <li>
        <img src="/images/system/blue_point.gif" class="icon-by-date"/><a id="all_users" href="#">所有用户</a>
      </li>
      <li>
        <img src="/images/system/blue_point.gif" class="icon-by-category"/><a id="password_info" href="#">修改密码</a>
      </li>
      <li>
        <img src="/images/system/exit.gif" class="icon-no-group"/><a id="agent_logout" href="#">退出系统</a>
      </li>
    </ul>
  </body>
</html>
